import React, { PropTypes, Component } from 'react'

import WidgetMenuLayout from './WidgetMenuLayout'
import WidgetMenuFont from './WidgetMenuFont'


 
class WidgetMenu extends Component {
 constructor(props, context) {
    super(props, context)    
  }

 widgetMenuRender(){
    let { widget,open }=this.props
    
    if(open){
      switch (widget.id){
        case 1:{
         return  <WidgetMenuLayout widget={widget} widgetSetConStyle={this.props.widgetSetConStyle} />
        }
        case 2:{
         return (<div> 
                    <WidgetMenuLayout key='widget-layout' 
                                      widget={widget} 
                                      widgetSetConStyle={this.props.widgetSetConStyle} />
                    <WidgetMenuFont key='widget-fonthot' 
                                       widget={widget}
                                       handleWidgetMenuShow={this.props.handleWidgetMenuShow}
                                       widgetSetElementStyle={this.props.widgetSetElementStyle} />
                </div>)
        }
        case 3:{
         return (<div> 
                    <WidgetMenuLayout key='widget-layout' 
                                      widget={widget} 
                                      widgetSetConStyle={this.props.widgetSetConStyle} />
                    
                </div>)
        }
      }
    }

 }
  render() {
    return (
     <div className="widgetMenu">{this.widgetMenuRender()}</div>
    )
     }
  }

WidgetMenu.propTypes = {
  widget:PropTypes.object,
  open:PropTypes.bool.isRequired,
  widgetSetConStyle:PropTypes.func.isRequired,
  widgetSetElementStyle:PropTypes.func.isRequired
}

export default WidgetMenu
